Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

411
Vistas
Query multiple fields with same value [GraphQL][Amplify]

I'm creating an API with AWS Amplify and AppSync GraphQL. I Work on a Tinder like App.

I would like to search the same value in two fields for a Query. I've tried a lot of solutions, but none seems to work.

I have a User @Model which is connected to many Match via @connection

type User @model
  @auth(rules: [{allow: public}])

    {
      id: ID!
      email: String!
      password: String
      age: String!
      name: String!
      description: String
      pickupLine: String
      orientation: Orientation!
      gender: Gender! 
      animal: Animal!
      profilePicture: String!
      pictures: [String]!
      location: Location
      numberOfSparksAvailable: Int!
      matchs: [Match]
        @connection(keyName: "byUser", fields: ["id"])
      sparks: [Spark]
        @connection(keyName: "byUser", fields: ["id"])
    }

And I have a Match @Model which have a senderId field and a receiverId field

type Match @model
  @auth(rules: [{allow: public}])
  
  @key(name: "byUser", fields: ["receiverId", "senderId"], queryField: "matchByUser")
  @key(name: "bySender", fields: ["senderId"], queryField: "sparkBySender")
  @key(name: "byReceiver", fields: ["receiverId"], queryField: "sparkByReceiver")
    {
      id: ID!
      status: MatchStatus!
      matchType: MatchType
      sender: User! @connection(fields: ["senderId"])
      senderId: ID!
      receiver: User! @connection(fields: ["receiverId"])
      receiverId: ID!
      answerFrom: Answer!
      answerTo: Answer
      chatRoomId: ID!
      chatRoom: ChatRoom!
        @connection(fields: ["chatRoomId"])
      deletedAt: AWSDate
    }

And and I don't find any way to make bySender @key look for both senderId and receiverId. I want to be able to have all the Matches for a User whether he's the receiver or the sender.

But when I make a Query to ListUsers I only get the Matches where the User is a receiver.

I've also tried to make multiple @connection but it is not allowed by Graphql-transformer.

I also tried to make an usersId: [ID!]! like that

type Match @model {
  ...
  usersId: [ID!]!
  users: [User!]!
    @connection(fields: ["usersId"])
  ...
}

But It's also not allowed by graphql-transformer..

Has anyone a solution to get all the matches for a User?

Thanks a lot !

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda